{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b1f8cd88-d79b-4f1a-ac2e-1b3c8a654fe6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "客户信息数据集\n",
      "    age  height  weight gender\n",
      "0    21     163      60      M\n",
      "1    22     164      56      M\n",
      "2    21     170      50      M\n",
      "3    23     168      56      M\n",
      "4    21     169      60      M\n",
      "..  ...     ...     ...    ...\n",
      "95   24     192      73      F\n",
      "96   25     187      74      F\n",
      "97   20     178      65      F\n",
      "98   23     172      76      F\n",
      "99   25     173      78      F\n",
      "\n",
      "[100 rows x 4 columns]\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "names = ['age','height','weight','gender']\n",
    "dataset=pd.read_csv('./item6/gender-data-y.txt',delimiter=',',names=names)\n",
    "print('客户信息数据集')\n",
    "print(dataset)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "9c429ee6-9cd8-421f-9308-a5e4af35a8c6",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "处理后的客户信息数据集\n",
      "    age  height  weight gender  label\n",
      "0    21   163.0    60.0      M      1\n",
      "1    22   164.0    56.0      M      1\n",
      "2    21   170.0    50.0      M      1\n",
      "3    23   168.0    56.0      M      1\n",
      "4    21   169.0    60.0      M      1\n",
      "..  ...     ...     ...    ...    ...\n",
      "95   24   192.0    73.0      F      0\n",
      "96   25   187.0    74.0      F      0\n",
      "97   20   178.0    65.0      F      0\n",
      "98   23   172.0    76.0      F      0\n",
      "99   25   173.0    78.0      F      0\n",
      "\n",
      "[100 rows x 5 columns]\n"
     ]
    }
   ],
   "source": [
    "from sklearn import preprocessing\n",
    "dataset['height']=dataset['height'].astype(float)\n",
    "dataset['weight']=dataset['weight'].astype(float)\n",
    "le=preprocessing.LabelEncoder()\n",
    "dataset['label']=le.fit_transform(dataset['gender'])\n",
    "print('处理后的客户信息数据集')\n",
    "print(dataset)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54085f05-16a8-4dc5-9ce9-4830ba920893",
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "data = dataset.iloc[range(0,100),range(1,3)].values\n",
    "target=dataset.iloc[range(0,100),range(4,5)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
